{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Kaggle football example",
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "metadata": {
        "id": "edvwsjsJsAQY",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "## Installing kaggle-environments.\n",
        "!pip install kaggle-environments\n",
        "\n",
        "# 4. Import register to define the environment and make to create it.\n",
        "from kaggle_environments import make, register"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "dWXjFxmDsiVb",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Installing Google Football environment.\n",
        "\n",
        "!apt-get update\n",
        "!apt-get install -y libsdl2-gfx-dev libsdl2-ttf-dev\n",
        "\n",
        "# Make sure that the Branch in git clone and in wget call matches !!\n",
        "!git clone -b v2.3 https://github.com/google-research/football.git\n",
        "!mkdir -p football/third_party/gfootball_engine/lib\n",
        "\n",
        "!wget https://storage.googleapis.com/gfootball/prebuilt_gameplayfootball_v2.3.so -O football/third_party/gfootball_engine/lib/prebuilt_gameplayfootball.so\n",
        "!cd football && GFOOTBALL_USE_PREBUILT_SO=1 pip3 install ."
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "4URn2BRvs3qL",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "env = make(\"football\", debug=True, configuration={\"scenario_name\": \"11_vs_11_kaggle\", \"team_1\": 1, \"team_2\": 1, \"running_in_notebook\": True, \"save_video\": True})\n",
        "print(env.name, env.version)\n",
        "print(\"Default Agents: \", *env.agents)\n",
        "\n",
        "env.run([\"run_right\", \"run_left\"])\n",
        " \n",
        "env.render(mode=\"html\", width=960, height=720)"
      ],
      "execution_count": 0,
      "outputs": []
    }
  ]
}
